
import com.cxhd.dc.DataConfig;
import com.cxhd.dc.task.ScanFileToZipTask;
import com.cxhd.dc.tool.FileUtil;
import com.cxhd.dc.tool.HttpClientUt;
import com.google.gson.Gson;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.dicom4j.dicom.DicomException;
import org.dicom4j.dicom.DicomTags;
import org.dicom4j.io.media.DicomFile;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Administrator
 */
public class test {

    public static void main(String[] args) {

//        String str = "kdla8405118*)(^%*YTILKH89015jfkhka";
//      str = str.replaceAll("[a-zA-Z]","" );
//      System.out.println(str);
      //  System.out.println(getOldPatientId("C:\\dcmsyst\\cache\\download\\ZY120424F\\1.3.51.0.7.1536902156.4210.9550.43170.26624.3902.12707.dcm"));
      Map<String,String> patientInfo = new HashMap<String,String>();
           patientInfo.put("studyIuid", "00000000111111");
               
                    patientInfo.put("pat_name", "系统消息");
               
                    patientInfo.put("pat_id", "000000000");
               
                    patientInfo.put("modality", "DX");
                
               
                   
                    patientInfo.put("pat_birth", "1900-00-00");
               
                    patientInfo.put("pat_sex", "男");
               
                   
                    patientInfo.put("pat_age", "0");
                    
                    sendMessage("147", patientInfo);

    }

    public static String getOldPatientId(String path) {
        DicomFile ldcm = new DicomFile(path);
        try {
            ldcm.open();
            return ldcm.getDataset().getElement(DicomTags.StudyInstanceUID).getSingleStringValue();
        } catch (Exception ex) {
            return null;
        } finally {
            try {
                ldcm.close();
            } catch (IOException ex) {
                ex.printStackTrace();

            } catch (DicomException ex) {
                ex.printStackTrace();
            }
        }

    }
    
    
     private static void sendMessage( String groupId,Map<String,String> patientInfo) {
        try {
         
                
               String content = "测试";
              

                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("groupId", groupId));
                params.add(new BasicNameValuePair("contact", content));
                params.add(new BasicNameValuePair("patientInfo", new Gson().toJson(patientInfo)));
                params.add(new BasicNameValuePair("from", "影像中心"));
               
                String returnMsg = HttpClientUt.httpPost("http://base.tronsystem.com:19027/app/message/sendGroupMessage.data", params);
                System.out.println("是否发送成功");
          
        } catch (Exception e) {
            //logger1.error(e);
            e.printStackTrace();
        }
    }
}
